package com.momoauth.common.log.dao;

import com.momoauth.common.log.entity.System_Log;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class SystemLogDao {

    @Resource
    JdbcTemplate jdbcTemplate;

    /**
     * 插入日志
     * @param system_log
     * @return
     */
    public int insertSystemLog(System_Log system_log) {
        String sql = "INSERT INTO system_log " +
                "(logId," +
                "requestMethod," +
                "requestIp," +
                "requestUrl," +
                "className," +
                "methodName," +
                "parameters," +
                "`value`," +
                "description," +
                "returnValue," +
                "executeTime) " +
                "VALUES (?,?,?,?,?,?,?,?,?,?,?)";
        return jdbcTemplate.update(sql,
                system_log.getLogId(),
                system_log.getRequestMethod(),
                system_log.getRequestIp(),
                system_log.getRequestUrl(),
                system_log.getClassName(),
                system_log.getMethodName(),
                system_log.getParameters(),
                system_log.getValue(),
                system_log.getDescription(),
                system_log.getReturnValue(),
                system_log.getExecuteTime()
        );
    }
}
